//
//  TabBarViewController.m
//  TeamProject_1.0
//
//  Created by lanou3g on 15/12/7.
//  Copyright © 2015年 wey. All rights reserved.
//

#import "TabBarViewController.h"

@interface TabBarViewController ()

@property (nonatomic, strong) NSArray *titles;
@property (nonatomic, strong) NSMutableArray *images;

@end

@implementation TabBarViewController


- (NSMutableArray *)images {
    if (!_images) {
        _images = [NSMutableArray array];
    }
    return _images;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setSubViews];
}

#pragma mark --- 设置tabbar
- (void) setSubViews {
    //    self.titles = @[@"综合", @"动弹", @"", @"发现", @"我"];
    //    self.images = @[@"tabbar-news", @"tabbar-tweet", @"", @"tabbar-discover", @"tabbar-me"];
    self.titles = @[@"精选", @"发现",@"我"];
    NSArray *imgpaths = @[@"tabbar-news", @"tabbar-discover",@"tabbar-me"];
    
    for (int i = 0; i<self.titles.count; i++) {
        [self.images addObject:[UIImage imageNamed:imgpaths[i]]];
    }
    
    [self setUpTabbar];
    
}

- (void)setUpTabbar {
    
    
    ///  资讯
    UIStoryboard *NewsSB = [UIStoryboard storyboardWithName:@"News" bundle:nil];
    UINavigationController *newsNC = [NewsSB instantiateViewControllerWithIdentifier:@"news"];
    newsNC.tabBarItem = [[UITabBarItem alloc]initWithTitle:self.titles[0] image:self.images[0] selectedImage:self.images[0]];
    
    ///  发现
    UIStoryboard *discoverSB = [UIStoryboard storyboardWithName:@"Discover" bundle:nil];
    UINavigationController *discoverNC = [discoverSB instantiateViewControllerWithIdentifier:@"discover"];
    discoverNC.tabBarItem = [[UITabBarItem alloc]initWithTitle:self.titles[1] image:self.images[1] selectedImage:self.images[1]];
    
    ///  我的
    UIStoryboard *mainSB = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UINavigationController *myNC = [mainSB instantiateViewControllerWithIdentifier:@"my"];
    myNC.tabBarItem = [[UITabBarItem alloc]initWithTitle:self.titles.lastObject image:self.images.lastObject selectedImage:self.images.lastObject];
    
    ///  子视图添加
    self.viewControllers = @[newsNC,discoverNC,myNC];
    self.tabBarController.selectedIndex = 0;
    self.tabBar.tintColor = [UIColor greenColor];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}



@end
